from PIL import Image, ImageDraw, ImageFont
import random, string, os

def random_code():
    return random.choice(string.ascii_uppercase) + ''.join(random.choices(string.digits, k=3))

font = ImageFont.truetype("FangSong.ttf", 48)
os.makedirs("output_dataset", exist_ok=True)

for i in range(1000):
    text = random_code()
    img = Image.new("RGB", (160, 64), (255,255,255))
    draw = ImageDraw.Draw(img)
    draw.text((20,10), text, font=font, fill=(0,0,0))
    img.save(f"output_dataset/{i+1:05d}.jpg")
    with open("output_dataset/labels.txt", "a", encoding="utf-8") as f:
        f.write(f"./251027/{i+1:05d}.jpg\t{text}\n")
